package com.study.util.domin;

/**
 * @version V1.0
 * @title: Test
 * @description: ${DESCRIPTION}
 * @author: wanghuilong
 * @date: 2019-10-18 17:21
 * @copyright: http://fingo.com.my/
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 1000; i++) {
                    System.out.println(i + "");
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        throw new RuntimeException(e); //必须抛出异常 不然还是会继续执行
                    }
                }

            }
        };

        Thread thread = new Thread(runnable);
        thread.start();

        thread.join(3000);
        thread.interrupt();
    }

}
